import { getReturnDetail } from "../../../network/order";

Page({
  data: {
    order_id:null,
    detailInfo:null
  },
  onLoad: function (options) {
    this.setData({order_id:options.order_id})
    //    调用网络请求
    this._getReturnDetail(options.order_id)

  },
  // 预览图片
  previewImg: function (e) {
    //获取当前图片的下标
    var index = e.currentTarget.dataset.index;
    //所有图片
    var pics = this.data.detailInfo.proof_pic;
    wx.previewImage({
      //当前显示图片
      current: pics[index],
      //所有图片
      urls: pics
    })
  },
  //       网络请求     //
  async _getReturnDetail(order_id){
    const res = await getReturnDetail(order_id)
    if(res.code === 200){
      this.setData({
        detailInfo: res.data
      })
    }else if(res.code === 400){
      setTimeout(()=>{
        wx.navigateBack({
          delta: 1
        });
      },1000)
    }
  }
})